#! /usr/bin/env ruby
# encoding: UTF-8
# frozen_string_literal: true

#
# Example program using blitz3d-parser-ruby library.
#
# Copyright 2022 陈睿超 (Chen, Ruichao) <sheep0x.moe@protonmail.com>
#
# This program is released under the GNU General Public License version 2 or
# (at your option) any later version.
#
# You should have received a copy of GPLv2 along with this program; if not,
# visit https://www.gnu.org/licenses/old-licenses/gpl-2.0.html to view the
# license.
#

require_relative '../parser-blitz3d.rb'


# Pick a simple file.  Otherwise you'll just see a boring wall of text.
binary_data = $stdin.read.force_encoding(Encoding::ASCII_8BIT)


# Example 1: default schema
pp Blitz3D.parse_file(binary_data)


# Example 2: disable post-processing
# Shows (almost) raw data, except “1 or more TRIS” is shown as “1 TRIS + 0 or more TRIS”.
schema = Blitz3D::DEFAULT_SCHEMA
           .transform_values {|*blah, postproc|  [*blah, nil]  }

pp Blitz3D.parse_file(binary_data, schema: schema)
